//
//  ChangeViewController.m
//  XingRun
//
//  Created by 赵颜彬 on 17/1/12.
//  Copyright © 2017年 赵颜彬. All rights reserved.
//

#import "ChangeViewController.h"

@interface ChangeViewController ()<UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, strong) UITableView *tableView;

@property (nonatomic, strong) NSArray *dataArr;

@end

@implementation ChangeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = @"添加地址";
    
    self.dataArr = @[@"买家姓名",@"手机号码",@"所在地区",@"详细地址"];
    
    //右侧
    UIButton *releaseButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [releaseButton setTitle:@"保存" forState:UIControlStateNormal];
    [releaseButton setTitleColor:[UIColor blackColor]forState:UIControlStateNormal];
    
    [releaseButton addTarget:self action:@selector(releaseInfo:) forControlEvents:UIControlEventTouchUpInside];
    releaseButton.frame = CGRectMake(0, 0, 40, 30);
    
    UIBarButtonItem *releaseButtonItem = [[UIBarButtonItem alloc] initWithCustomView:releaseButton];
    self.navigationItem.rightBarButtonItem = releaseButtonItem;
    
    [self cretableView];
}
-(void)cretableView{
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, -29, self.view.bounds.size.width, self.view.bounds.size.height) style:UITableViewStyleGrouped];
    self.tableView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:_tableView];
    
    _tableView.delegate = self;
    _tableView.dataSource = self;
    
    
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return _dataArr.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

        UITableViewCell  *cell= [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"];
    cell.selectionStyle=UITableViewCellSelectionStyleNone;//设置
    cell.textLabel.text = _dataArr[indexPath.row];
    if (indexPath.row == 2) {
        UIImageView *img= [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"箭头"]];
        img.frame = CGRectMake(350 * WIDTH, 10 * HEIGHT, 8 * WIDTH, 16 * HEIGHT);
        [cell addSubview:img];
    }
        return cell;

    
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 40 *HEIGHT;
}

-(void)releaseInfo:(UIButton *)btn{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
